<?php

namespace App\Http\Resources;

use App\Helpers\BaseResource;

class Withdraw extends BaseResource
{
    public function toArray($request)
    {
        return $this->filterFields([
            'title' => '余额提现',
            'money' => $this->money,
            'ac_type' => $this->ac_type,
            'remark' => $this->remark,
            'time' => (string)$this->created_at,
            'check_time' => (string)$this->check_time,
            'state' => $this->setState(),
            'state_key' => $this->state
        ]);
    }

    private function setState()
    {
        switch ($this->state) {
            case 0:
                $state = '审核中';
                break;
            case 1:
                $state = '已到账';
                break;
            case 2:
                $state = '未通过';
                break;
            case 3:
                $state = '已退款';
                break;
            default:
                $state = "审核中";
                break;
        }

        return $state;

    }
}
